﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Quartz;
using iTelluro.Explorer.Infrastructure.CrossCutting.Logging;
using iTelluro.Explorer.Infrastructure.CrossCutting.NetFramework.Logging;
using SXMeteorological.Data.Utility;
namespace SXMeteorological.DataSyn.Press
{
    public class PressJob:IJob
    {
        private readonly ILogger _logger;
        public PressJob()
        {
            _logger = LoggerFrameFactory.CreateLog();
            _logger.LogInfo("执行气压任务构造函数");
        }

        public void Execute(IJobExecutionContext context)
        {
            HourPRS_Sea();
            HourStationLowerPRS();
            HourStationPRS();
            HourStationTopPRS();
        }

        private void HourPRS_Sea()
        {
            try
            {
                string interfaceName = "getSurfEleInRegionByTime";
                string returnValue = "Lat,Lon,PRS_Sea";
                string featureName = "海平面气压";
                string time = DateTime.Now.AddHours(-1).ToString("yyyyMMddHH") + "0000";
                string dataCode = "SURF_CHN_MUL_HOR";
                string colorpath = AppDomain.CurrentDomain.BaseDirectory + @"color\Press.txt";
                CreateMap.CreateFeatureMap(interfaceName, returnValue, dataCode, featureName, "海平面气压图", time, colorpath, "h");
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("陕西省海平面气压数据生成失败#{0}：{1}", DateTime.Now, ex.Message));
            }
        }

        private void HourStationPRS()
        {
            try
            {
                string interfaceName = "getSurfEleInRegionByTime";
                string returnValue = "Lat,Lon,PRS";
                string featureName = "本站气压";
                string time = DateTime.Now.AddHours(-1).ToString("yyyyMMddHH") + "0000";
                string dataCode = "SURF_CHN_MUL_HOR";
                string colorpath = AppDomain.CurrentDomain.BaseDirectory + @"color\Press.txt";
                CreateMap.CreateFeatureMap(interfaceName, returnValue, dataCode, featureName, "本站气压图", time, colorpath, "h");
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("陕西省本站气压数据生成失败#{0}：{1}", DateTime.Now, ex.Message));
            }
        }

        private void HourStationTopPRS()
        {
            try
            {
                string interfaceName = "getSurfEleInRegionByTime";
                string returnValue = "Lat,Lon,PRS_Max";
                string featureName = "小时最高本站气压";
                string time = DateTime.Now.AddHours(-1).ToString("yyyyMMddHH") + "0000";
                string dataCode = "SURF_CHN_MUL_HOR";
                string colorpath = AppDomain.CurrentDomain.BaseDirectory + @"color\Press.txt";
                CreateMap.CreateFeatureMap(interfaceName, returnValue, dataCode, featureName, "小时最高本站气压图", time, colorpath, "h");
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("陕西省小时最高本站气压数据生成失败#{0}：{1}", DateTime.Now, ex.Message));
            }
        }

        private void HourStationLowerPRS()
        {
            try
            {
                string interfaceName = "getSurfEleInRegionByTime";
                string returnValue = "Lat,Lon,PRS_Min";
                string featureName = "小时最低本站气压";
                string time = DateTime.Now.AddHours(-1).ToString("yyyyMMddHH") + "0000";
                string dataCode = "SURF_CHN_MUL_HOR";
                string colorpath = AppDomain.CurrentDomain.BaseDirectory + @"color\Press.txt";
                CreateMap.CreateFeatureMap(interfaceName, returnValue, dataCode, featureName, "小时最低本站气压图", time, colorpath, "h");
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("陕西省小时最低本站气压数据生成失败#{0}：{1}", DateTime.Now, ex.Message));
            }
        }
    }
}
